<?php

defined('_JEXEC') or die;
require_once (JPATH_COMPONENT.DIRECTORY_SEPARATOR.'helpers'.DIRECTORY_SEPARATOR.'utils.php');
class BakerysModelOrders extends JModelList
{

	public function __construct($config = array())
	{
		parent::__construct($config);
	}

	protected function populateState($ordering = null, $direction = null)
	{
		$app = JFactory::getApplication('administrator');

		$published = $this->getUserStateFromRequest($this->context.'.filter.states', 'filter_state', '', 'string');
		$this->setState('filter.state', $published);

		// Load the parameters.
		$params = JComponentHelper::getParams('com_bakerys');
		$this->setState('params', $params);

		// List state information.
		parent::populateState('o.customer_name', 'asc');
	}

	protected function getListQuery()
	{
		// Create a new query object.
		$db		= $this->getDbo();
		$query	= $db->getQuery(true);
		$user	= JFactory::getUser();				
		$isAdmin = $user->get("isRoot");		
		
		// Select the required fields from the table.
		$query->select("o.*");
		$query->from("#__bakery_orders o");
		$published = $this->getState('filter.state');
			
		return $query;
	}	
}
